﻿using System;

namespace ArrayFunctions
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = GetRandomArray(10, 0, 100);
            PrintArray(a, "a");

            int[] b = GetRandomArray(10, -100, 100);
            PrintArray(b, "b");

            long[] c = MultiplyArray(a, b);
            PrintArray(c, "mul");

            Console.WriteLine("min = " + GetArrayMin(c));
            Console.WriteLine("sum = " + GetArraySum(c));
            Console.WriteLine("avr = " + GetArrayAvr(c));

            

            Console.ReadKey();
        }

        static double GetArrayAvr(long[] array)
        {
            return GetArraySum(array) / (double)array.Length;
        }
        static long GetArraySum(long[] array)
        {
            long sum = 0;
            for (int i = 0; i < array.Length; i++)
            {
                sum += array[i];
            }
            return sum;
        }

        static long GetArrayMin(long[] array)
        {
            long min = array[0];
            for (int i = 1; i < array.Length; i++)
            {
                if (array[i] < min)
                {
                    min = array[i];
                }
            }

            return min;
        }

        static int[] GetRandomArray(int length, int minValue, int maxValue)
        {
            int[] array = new int[length];

            Random rnd = new Random();

            for (int i = 0; i < length; i++)
            {
                array[i] = rnd.Next(minValue, maxValue);
            }

            return array;
        }

        static void PrintArray(int[] array, string name)
        {
            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(name + "[" + i + "] = " + array[i]);
            }

            Console.WriteLine();
        }

        static void PrintArray(long[] array, string name)
        {
            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(name + "[" + i + "] = " + array[i]);
            }

            Console.WriteLine();
        }

        static long[] MultiplyArray(int[] a, int[] b)
        {
            if (a.Length != b.Length)
            {
                return new long[0];
            }

            long[] c = new long[a.Length];

            for (int i = 0; i < a.Length; i++)
            {
                c[i] = a[i] * b[i];
            }

            return c;
        }

        //static double F(double x)
        //{
        //    return 5 * x + 7;
        //}
    }
}
